package com.gonsin.gview.model.menu;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.gonsin.gview.model.i18n.TCloneable;
import com.gonsin.i18n.logic.T;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 菜单结构
 */
@Data
@ApiModel("菜单结构")
public class GViewMenu implements TCloneable<GViewMenu> {

    @ApiModelProperty("菜单的主键")
    private String name;

    @ApiModelProperty("菜单标题")
    private String title;

    @ApiModelProperty("父级菜单主键")
    private String parent;

    @ApiModelProperty("菜单点击路径")
    private String url;

    @ApiModelProperty("菜单图标")
    private String icon;

    @ApiModelProperty("菜单类型(枚举MenuType)")
    private Integer menuType;

    public GViewMenu(String name, String title, String parent, String url, String icon) {
        this.name = name;
        this.title = title;
        this.parent = parent;
        this.url = url;
        this.icon = icon;
    }

    public GViewMenu() {
    }

    @Override
    public GViewMenu tClone() {
        GViewMenu menu = new GViewMenu();
        BeanUtil.copyProperties(this, menu, CopyOptions.create().setIgnoreNullValue(true));
        if(title != null){
            menu.setTitle(T.t(title));
        }
        return menu;
    }
}
